<template>
  <div>
    <!-- 全部订单内容样式排版 -->
    <ul>
      <li v-for="(item, index) in recordsVal" :key="index">
        <!-- 上部结构 -->
        <div class="descript_cont">
          <span>{{ item.prodName }}</span>
          <span>&gt;</span>
        </div>
        <!-- 中部结构 -->
        <div class="count_order">
          <div class="zuo"></div>
          <div class="you">
            <h3>{{ item.title }}</h3>
            <p class="p1"><span>发货时间</span>{{ item.orderTime }}</p>
            <p><span>下单人</span>{{ item.orderUserName }}</p>
          </div>
        </div>
        <!-- 下部状态按钮结构 -->
        <div class="btn_sub">
          <van-button
            color="#FFCC33"
            size="small"
            @click="Pingjia(item.serialNo)"
            >{{ butVal }}</van-button
          >
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { GetOrderAllData } from "@/request/api";
export default {
  data() {
    return {
      recordsVal: [],
      butVal: "评价",
    };
  },
  created() {
    GetOrderAllData({
      current: 1,
      size: 20,
      keyword: "",
    }).then((res) => {
      //   console.log(res.data);
      this.recordsVal = res.data.records;
      // 判断订单状态，给按钮赋予正确的值
      this.recordsVal.map((item) => {
        if (item.status == 0) {
          this.butVal = "发货";
        } else if (item.status == 10) {
          this.butVal = "收货";
        } else if (item.status == 20) {
          this.butVal = "评价";
        } else if (item.status == 30) {
          this.butVal = "查看评价";
        }
      });
    });
  },
  methods: {
    // 判断按钮状态，来进行正确的页面跳转,评价与查看评价
    Pingjia(val) {
      console.log(this.butVal);
      this.butVal == "评价"
        ? this.$router.push("/order/dingdanpingjia?id=" + val)
        : this.$router.push("/order/chakanpingjia?id=" + val);
      // if ((this.butVal = "评价")) {
      //   this.$router.push("/order/dingdanpingjia?id=" + val);
      // } else if ((this.butVal = "查看评价")) {
      //   this.$router.push("/order/chakanpingjia?id=" + val);
      // }
    },
  },
};
</script>
 
<style lang = "less" scoped>
li {
  width: 100%;
  background-color: white;
  box-sizing: border-box;
  margin-top: 0.1rem;
  .descript_cont {
    height: 0.5rem;
    line-height: 0.5rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #efefef;
    padding: 0 0.2rem;
  }
  /* 订单描述的具体内容样式 */
  .count_order {
    width: 100%;
    padding: 0.2rem;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    .zuo {
      height: 0.7rem;
      width: 0.7rem;
      background-color: wheat;
      margin-right: 0.1rem;
    }
    .you {
      height: 0.7rem;
      flex: 1;
      background-color: yellow;
      p {
        span {
          margin-right: 0.1rem;
        }
      }
      .p1 {
        line-height: 0.4rem;
      }
    }
  }
  .btn_sub {
    height: 0.5rem;
    padding: 0.1rem 0.2rem;
    box-sizing: border-box;
    border-top: 1px solid #efefef;
    .van-button {
      float: right;
      border-radius: 0.15rem;
      padding: 0 0.15rem;
    }
  }
}
</style>